# -*- coding: iso-8859-15 -*-
'''
Created on 10/01/2010

@author: carlos
'''
import unittest
from core.Account import Account,InvalidDC
from core.User import User


class Test(unittest.TestCase):

    def setUp(self):
        self.__cccs = [21050020511270000066, 21000150630200455826 ]
        self.__names = ['a', 'b']
        self.__users = [User('carlos', 'carlosvin@gmail.com'), User('jelen', 'jelenrobles@gmail.com')]

    def tearDown(self):
        pass

    def testAccountsInvalid(self):
        try:
            print Account('asd',12341234121234567890)
        except InvalidDC as e:
            print 'dc invalido:' + str(e.value)
          
    def testAccountsValid(self):          
        for ccc in self.__cccs:
            print Account('a',ccc)
            print Account('a',str(ccc))
            print Account('a', ccc)
            
    def testUserAccount(self):
        
        for usr in self.__users:
            i=0
            for name in self.__names:
                usr.add_account(Account(name, self.__cccs[i]))
                i+=1
        
        for usr in self.__users:
            i=0
            for name in self.__names:
                account = usr.get_account(name)
                self.assertEquals(account.name, name ) 
                self.assertEquals(account.ccc, str(self.__cccs[i]))       
                i+=1  

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()